home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk125 / usmap / domap < prev    next >
Text File  |  1995-03-19  |  4KB  |  193 lines

  1.  
  2.     setblack 1
  3.     load 1,"usmap1"        :rem  read visible map
  4.     load 2,"usmap2"        :rem  read button mask
  5.  
  6. rem  create button table array
  7.     array 500,2
  8.     table=100    :rem  location of button table
  9.  
  10.     gosub 980    :rem  go read in the button table
  11.  
  12.     new 3,1        :rem  dup a copy of main screen (for highlighting)
  13.     copy 1,3
  14.  
  15.     abort 0        :rem  disable mouse abort
  16.     fade 1,-1,0    :rem  reveal screen
  17.     pointer 1    :rem  turn pointer on
  18.     demo=0
  19.  
  20. 8    gosub 950    :rem  start up in demo mode
  21.     goto 111    :rem  exited demo mode
  22.  
  23. 10
  24.     blitdest -1
  25.     dissolve 3,0,0,0,0,-1,-1,3000    :rem  dissolve to original map
  26.  
  27. 111
  28.     if demo=0:gosub 940:endif    :rem  get mouse input (with timeout )
  29.     demo=0
  30.     gosub 900            :rem  determine which button clicked
  31.     if butcount=0:goto 10:endif    :rem  no button clicked
  32.  
  33.     gosub 920            :rem  highlight the selection
  34.     pause 2
  35.  
  36.     if butcount=49:end:endif    :rem  exit button
  37.     if butcount=50:goto 8:endif    :rem  demo button
  38.  
  39. rem  create area for information text
  40.     pen 1,7
  41.     rect 74,54,254,154
  42.     pen 1,23
  43.     rect 70,50,250,150
  44.  
  45. rem  build state data file name
  46.     string "state",$(0)
  47.     @(5)=48+butcount/10    :rem  add 10s digit
  48.     @(6)=48+butcount%10    :rem  add 1s digit
  49.     @(7)=0            :rem  end of name string
  50.     center 1        :rem  center the text
  51.     pen 1,0            :rem  pen color
  52.  
  53. rem  open state data file
  54.  
  55.     mode=0
  56.     open mode,$(0)
  57.     if mode=0        :rem  data file not found
  58.         drawmode 0    :rem  no background color
  59.         move 0,90
  60.         text "No data file"
  61.         move 0,110
  62.         text "on this state"
  63.         drawmode -1
  64. 12
  65.         gosub 940    :rem  check for mouse click (w/timeout)
  66.         goto 10        :rem  dissolve the selection away now
  67.     endif
  68.     vert=70        :rem  y location for text
  69.  
  70. 11
  71.     read v,$(0),80    :rem  get a line from data file
  72.     if v=-1
  73.        close    :rem  end of file, no more data
  74.        goto 12
  75.     endif
  76.  
  77.     move 0,vert    :rem position on screen
  78.     drawmode 0    :rem  no background color
  79.     text $(0)    :rem  display the data line
  80.     drawmode -1    
  81.     vert=vert+14    :rem  down to next line
  82.     goto 11        :rem  read next line
  83.  
  84.  
  85. rem  determine button clicked
  86. 900
  87.     blitdest 2        :rem  select button mask image
  88.     getpen pcolor,x,y    :rem  get color of pixel from mask
  89.     blitdest -1        :rem  back to normal
  90.  
  91.     butcount=0        :rem  start at beginning of table
  92. 901
  93.     t=table+butcount*butsize
  94.     if @(t)=-1:butcount=0:return:endif    :rem  no more buttons
  95.     butcount=butcount+1            :rem  check next button
  96.  
  97. rem  x,y and color all must match
  98.     if x>@(t) & y>@(t+1) & x<@(t+2) & y<@(t+3) & pcolor=@(t+4)
  99.         return        :rem  we found our button
  100.     endif
  101.     goto 901
  102.  
  103.  
  104. rem  highlight the selection
  105. 920
  106.     t=table+(butcount-1)*butsize    :rem  locate button in table
  107.  
  108. rem  get button parameters
  109.     xa=@(t):ya=@(t+1):xb=@(t+2):yb=@(t+3):pcolor=@(t+4)
  110.     x=@(t+5):y=@(t+6)
  111.  
  112. 952
  113.     blitdest 2        :rem  output to mask buffer
  114.     pen 1,0            :rem  clear the button to color 0
  115.     getpen bcl,x,y    :rem  remember old color so we can restore later
  116.     fill 1,x,y
  117.  
  118. rem  make a blank screen of color 31 to use as highlighting
  119.     new 5,-1
  120.     blitdest 5
  121.     pen 0,31
  122.     clear
  123.  
  124.     blitdest -1        :rem  output back to screen
  125.     pen 0,0
  126.     stencil 5,2,0        :rem  stencil in the highlight
  127.     pen 1,bcl
  128.     blitdest 2        :rem  output to mask buffer
  129.     fill 1,x,y        :rem  recolor in the button
  130.     blitdest -1        :rem  output back to screen
  131.     free 5            :rem  done with highlight screen
  132.     return
  133.  
  134.  
  135. rem  check for mouse input with timeout
  136. 940
  137.     demo=0
  138.     timeout=100
  139. 941
  140.     ifmouse x,y
  141.     if x=-1
  142.         pause 1
  143.         timeout=timeout-1
  144.         if timeout=0:gosub 950:return:endif    :rem  do demo
  145.         goto 941
  146.     endif
  147.     return
  148.  
  149.  
  150. rem  do demo & attract mode
  151. 950
  152.     demo=1        :rem signal demo mode
  153.     lastpic=-1
  154. 959
  155.     z=1+?48        :rem  select a state at random
  156.     if z=lastpic:goto 959:endif    :rem  same as last choice?  re-pick
  157.     lastpic=z    :rem  remember so we don't select it next time
  158.     butcount=z
  159.     copy 3,1    :rem  erase old selection by restoring screen
  160.     gosub 920    :rem  highlight the new selection
  161.     ifmouse x,y
  162.     if x#-1        :rem  mouse clicked to abort demo mode?
  163.         blitdest -1:copy 3,1:return    :rem  yep, exit
  164.     endif
  165.     pause 3
  166.     goto 959
  167.  
  168.  
  169. 980 rem  read in the button data table
  170.     mode=0
  171.     open mode,"us.table"
  172.     if mode=0
  173.         print "can't find 'us.table' file"
  174.         end
  175.     endif
  176.  
  177.     butsize=7        :rem  size of table entry
  178.     t=table
  179. 4
  180.     read v,$(0),80        :rem  read a table entry
  181.     if v=-1
  182.         print "premature end of file in 'us.table'"
  183.         end
  184.     endif
  185.     n=$(0)        :rem  convert to a number
  186.     @(t)=n        :rem  place in table
  187.     t=t+1        :rem  next location
  188.     if n#-1:goto 4:endif    :rem  not end of table?  go to 4
  189.  
  190.     close        :rem  close file
  191.     return
  192.  
  193.